function scriptLoaded(oScript)
{
	if (oScript.src)
		debugWrite('Loaded reference: ' + oScript.src);
	else
		debugWrite('Loaded inline: ' + oScript.text.substring(0, 20) + '...');
}

function debugWrite(s)
{
	dnn.dom.getById('txt').value += s + '\n';
}

function loaddiag()
{
	dnn.dom.loadScript('../js/dnn.diagnostics.js', null);
}

function loadx()
{
	dnn.dom.loadScript(null, 'var x=123;');
}

function testsample1()
{
	debugWrite('--- testing variables ---');
	testValue('dnn.diagnostics');
	testValue('x');
	debugWrite('-------------------------');
}

function testsample2()
{
	debugWrite('--- testing variables ---');
	testValue('s1');
	testValue('s2');
	testValue('s3');
	testValue('s4');
	testValue('s5');
	debugWrite('-------------------------');
}

function testValue(o)
{
    try
    {
        debugWrite('Script Variable ' + o + ': ' + eval(o));
    }
    catch(e)
    {
		debugWrite('Script Variable ' + o + ': undefined');    
	}
}

function loadmultiple()
{
	debugWrite('loading multiple...');
	dnn.dom.loadScript('DynamicLoadScript/DynamicLoadScript.aspx-1.js', null, scriptLoaded);
	dnn.dom.loadScript('DynamicLoadScript/DynamicLoadScript.aspx-2.js', null, scriptLoaded);
	dnn.dom.loadScript('DynamicLoadScript/DynamicLoadScript.aspx-3.js', null, scriptLoaded);
	dnn.dom.loadScript('DynamicLoadScript/DynamicLoadScript.aspx-4.js', null, scriptLoaded);
	dnn.dom.loadScript('DynamicLoadScript/DynamicLoadScript.aspx-5.js', null, scriptLoaded);
	dnn.dom.loadScript(null, "debugWrite('s1 will be undefined, since scripts are loaded async: ' + typeof(s1));", scriptLoaded);
}

function loadmultiplewait()
{
	debugWrite('loading multiple waiting for async...');
	dnn.dom.loadScripts(['DynamicLoadScript/DynamicLoadScript.aspx-1.js', 
						'DynamicLoadScript/DynamicLoadScript.aspx-2.js', 
						'DynamicLoadScript/DynamicLoadScript.aspx-3.js', 
						'DynamicLoadScript/DynamicLoadScript.aspx-4.js', 
						'DynamicLoadScript/DynamicLoadScript.aspx-5.js'],
						["debugWrite('s1 will be defined, even though ref scripts are loaded async: ' + typeof(s1));"],
						allLoaded);
}

function allLoaded(oBatch)
{
	debugWrite('all scripts loaded (' + oBatch.numComplete + ')');
}
